home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
NOVA - For the NeXT Workstation
/
NOVA - For the NeXT Workstation.iso
/
SourceCode
/
Project_3
/
Calculator.m
< prev
next >
Wrap
Text File
|
1992-12-19
|
1KB
|
60 lines
/* Generated by Interface Builder */
#import <appkit/Form.h>
#import "Calculator.h"
extern double sqrt(double);
@implementation Calculator
- init
{
[super init];
calcType = TEMP;
return self;
}
- calculate:sender
{
[inputForm selectTextAt:0];
if (calcType == TEMP) {
float degreesF;
degreesF = ((9.0 * [inputForm floatValue])/5.0)+32.0;
[outputForm setFloatValue:degreesF at:0];
} else if (calcType == SQROOT) {double sqRoot;
sqRoot= sqrt((double)[inputForm floatValueAt:0]);
[outputForm setFloatValue:(float)sqRoot at:0];
}
return self;
}
- convertToTemp:sender
{
/* label input and output fields */
calcType = TEMP;
[inputForm setTitle:"Celsuis:" at:0];
[outputForm setTitle:"Fahrenheit:" at:0];
[outputForm setStringValue:"" at:0];
[inputForm display];
[outputForm display];
[inputForm selectTextAt:0];
return self;
}
- convertToSqRoot:sender
{
/* label input and output fields */
calcType = SQROOT;
[inputForm setTitle:"x:" at:0];
[outputForm setTitle:"sqrt(x):" at:0];
[outputForm setStringValue:"" at:0];
[inputForm display];
[outputForm display];
[inputForm selectTextAt:0];
return self;
}
@end